package br.com.edoc.entidade;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name="PERMISSAOUSUARIO")
public class PermissaoUsuario implements EntidadePadrao{
	

	

	/**
	 * 
	 */
	private static final long serialVersionUID = 7166504117915980574L;
	@Id  
	@Column(name = "PEU_IDDOOBJETO", nullable = false)  
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Integer id;
	@ManyToOne
    @JoinColumn(name="ME_IDDOOBJETO")
	private MenuFolha menu;
	@ManyToOne
    @JoinColumn(name="PRU_IDDOOBJETO") 
	private Perfil perfil;
	@Column(name = "PEU_INCLUIR")
	private Boolean incluir;
	@Column(name = "PEU_ALTERAR")
	private Boolean alterar;
	@Column(name = "PEU_EXCLUIR")
	private Boolean excluir;
	
	@Override
	public Integer getId() {
		// TODO Auto-generated method stub
		return id;
	}

	public MenuFolha getMenu() {
		if(menu == null){
			menu = new MenuFolha();
		}
		return menu;
	}

	public void setMenu(MenuFolha menu) {
		this.menu = menu;
	}

	public Boolean getIncluir() {
		return incluir;
	}

	public void setIncluir(Boolean incluir) {
		this.incluir = incluir;
	}

	public Boolean getAlterar() {
		return alterar;
	}

	public void setAlterar(Boolean alterar) {
		this.alterar = alterar;
	}

	public Boolean getExcluir() {
		return excluir;
	}

	public void setExcluir(Boolean excluir) {
		this.excluir = excluir;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Perfil getPerfil() {
		return perfil;
	}

	public void setPerfil(Perfil perfil) {
		this.perfil = perfil;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		PermissaoUsuario other = (PermissaoUsuario) obj;
		if ((other.id != null && this.id !=null) && !id.equals(other.id))
			return false;
		if (menu == null) {
			if (other.menu != null)
				return false;
		} else if (!menu.equals(other.menu))
			return false;
		return true;
	}

	
}
